package com.example.myapplication.ui;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ExecutorsUtils {

    private static class SingleUtils{
        private static final ExecutorsUtils DEFAULT_UTILS = new ExecutorsUtils();
    }

    private ExecutorsUtils() {
    }

    public static ExecutorsUtils get(){
        return SingleUtils.DEFAULT_UTILS;
    }

    private static final ExecutorService fixPool = Executors.newFixedThreadPool(5);
    private static final ExecutorService singlePool = Executors.newSingleThreadExecutor();
    private static final ExecutorService customPool = new ThreadPoolExecutor(
            1,
            5,
            5000,
            TimeUnit.MILLISECONDS,
            new ArrayBlockingQueue<>(100));

    public  ExecutorService getFixThread(){
        return fixPool;
    }

    public  ExecutorService getSingleThread(){
        return singlePool;
    }

    public  ExecutorService getCustomThread(){
        return customPool;
    }

}
